void selectSort(int *array, int length) {
    for (int i = 0; i < length - 1; ++i) {
        int index = i;
        int value = array[i];

        for (int j = i + 1; j < length; ++j) {
            if (array[j] < value) {
                index = j;
                value = array[j];
            }
        }

        if (index != i) {
            int temp = array[i];
            array[i] = array[index];
            array[index] = temp;
        }
    }
}